<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<link rel="stylesheet" href="../../layui/css/formSelects-v4.css" media="all">
<link rel="stylesheet" href="../../statics/lib/layui/css/layui.css" media="all">
<body>
<hr>
<!--搜索框-->
<form class="layui-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">操作人</label>
            <div class="layui-input-inline" style="width: 200px;">
                <input style="" id="handlePersonId" type="text" name="price_min" autocomplete="off" class="layui-input">
            </div>

            <div class="layui-input-inline" style="width: 100px;">
                <button type="button" class="layui-btn layui-btn-normal" onclick="searchData();"><i
                        class="layui-icon layui-icon-search"></i> 查询
                </button>
            </div>
        </div>

    </div>
</form>

<table class="layui-hide" id="test" lay-filter="test"></table>
</body>

<script>

    var table;
    layui.use(["table", "form"], function () {
        table = layui.table;
        table.render({
            elem: '#test'
            , url: '/log/getLogList'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , height: 600
            , title: '物品数据表'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'id', title: 'ID', sort: true, fixed: 'left', width: 70}
                , {field: 'handlePerson', title: '操作人', width: 100}
                , {field: 'handlePersonNo', title: '操作人学号', width: 150}
                , {
                    field: 'handleTime', title: '操作时间',
                    templet: function (d) {
                        return dateToStr(d.handleTime);
                    }, width: 200
                }
                , {field: 'handleType', title: '操作类型', width: 100}
                , {field: 'handleThing', title: '操作详情', width: 300}
                , {field: 'handleArgs', title: '操作参数', width: 550}
                , {field: 'handleResult', title: '操作结果'}
            ]]
            , page: true
        });
    });

    function dateToStr(date) {
        if (null == date || "" === date) {
            return "";
        }
        var time = new Date(date);
        var y = time.getFullYear();
        var M = time.getMonth() + 1;
        M = M < 10 ? ("0" + M) : M;
        var d = time.getDate();
        d = d < 10 ? ("0" + d) : d;
        var h = time.getHours();
        h = h < 10 ? ("0" + h) : h;
        var m = time.getMinutes();
        m = m < 10 ? ("0" + m) : m;
        var s = time.getSeconds();
        s = s < 10 ? ("0" + s) : s;
        var str = y + "-" + M + "-" + d + " " + h + ":" + m + ":" + s;
        return str;
    }

    function searchData() {
        var page = $(".layui-laypage-em").next().html();
        layui.table.reload("test", {
            page: {
                curr: page
            },
            where: {
                "handlePerson": $("#handlePersonId").val()
            }
        });
    }

</script>
